package com.sheep.provider;

import com.sheep.spark.util.SparkSupport;
import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;


/**
 * Created with IntelliJ IDEA.
 * User: Administrator
 * Date: 16-3-24
 * Time: 上午9:38
 * To change this template use File | Settings | File Templates.
 */
public class ProviderMainApp {

    private static Logger log = Logger.getLogger(ProviderMainApp.class) ;

    public static ApplicationContext springContext = null;

    /**
     * 启动服务
     * @return
     */
    public static boolean startApp() {
        SparkSupport.init();
        PropertyConfigurator.configure(System.getProperty("user.dir") + "/conf/log4jprovider.properties");
        if(springContext == null) {
            springContext = new FileSystemXmlApplicationContext("conf/provider.xml");
        }
        log.info("********************服务端启动*******************");
        return true;
    }

    public static void main(String[] args){
        startApp();
        waitForStop();
    }

    private static void waitForStop() {
        while (true) {
            try {
                Thread.sleep(Long.MAX_VALUE);
            } catch (InterruptedException e) {
                break;
            }
        }
    }
}
